package com.lyj.mp.domain.result;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result {
    private Integer code; // 1成功 2失败
    private String msg;   // 返回信息
    private Object data;  // 数据

    // 成功且要返回值
    public static Result success(Object data){
        return new Result(1,"success",data);
    }

    // 成功没有返回值
    public static Result success(){
        return new Result(1,"success",null);
    }

    // 失败返回失败信息
    public static Result error(String msg){
        return new Result(0,msg,null);
    }
}
